<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.commons.Constants,
                java.util.ArrayList"%>

<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/searchPurchaseOrders.do"/>
<%
    try{

%>


<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>

<SCRIPT language="JavaScript">

<%
	com.scalar.chiptrack.finance.openpo.forms.OpenPurchaseOrderForm purchaseForm = (com.scalar.chiptrack.finance.openpo.forms.OpenPurchaseOrderForm)session.getAttribute( "openPurchaseOrderForm" );
	ArrayList addressList = purchaseForm.getFormattedShippingAddressList();
	ArrayList vendorAddressList = purchaseForm.getFormattedShippingVendorAddressList();
%>
    var shipAddress       = new Array(<%=addressList.size()%>);
    var vendorShipAddress     = new Array(<%=vendorAddressList.size()%>)
<%
	for( int l = 0; l < addressList.size(); l++ )
    {
%>
	shipAddress[ <%=l%> ] = '<%=((String)addressList.get(l)).replace('\n','~').replaceAll("'","\\\\" + "'")%>';
<%
	}
%>
<%
	for( int i = 0; i < vendorAddressList.size(); i++ )
    {
%>
	vendorShipAddress[ <%=i%> ] = '<%=((String)vendorAddressList.get(i)).replace('\n','~').replaceAll("'","\\\\" + "'")%>';
<%
	}
%>

function onloadSetShippingAddress()
{
	loadShippingAddress();
}

var prevPrice = '';
var commentsMaxLength = 300;

function openCalendar(dateValue)
{
	dateElement = dateValue;
	newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','calenderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
	newWindow.moveTo(550,180);
	newWindow.focus();
}

function assignDate(passedValue)
{
	dateElement.value=passedValue;
	window.focus();
}

function openRelatedPOsScreen( purchaseOrder_Id )
{
	newWindow = window.open('<%=chipTracContext%>/openPurchaseOrder.do?action=relatedPOS&purchaseOrder_id='+purchaseOrder_Id,'relatedPOsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=580,height=300,resizable=no');
	newWindow.moveTo(220,180);
	newWindow.focus();
}

function openAuditTrail( purchaseOrder_Id, poNumber )
{
	newWindow=window.open('<%=chipTracContext%>/openPurchaseOrder.do?action=auditTrail&purchaseOrder_id='+purchaseOrder_Id+'&poNumber='+poNumber,'auditTrailPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=700,left=100,top=50,resizable=yes');
	newWindow.moveTo(100,50);
	newWindow.focus();
}

function openReasonCodes()
{
	newWindow = window.open('<%=chipTracContext%>/reasonCodes.do?action=Show', 'reasonCodesPopup', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,top=0,left=0,height=300,widht=500,resizable=yes');
    newWindow.focus();
}

function generatePurchaseOrder()
{
    var errors = '';

    var poDate = document.openPurchaseOrderForm.poDate.value;
    var validFromDate = document.openPurchaseOrderForm.validFromDate.value;
    var validToDate = document.openPurchaseOrderForm.validToDate.value;
    var poMaxAmt = document.openPurchaseOrderForm.poMaxAmt.value;
    var commentsValue = document.openPurchaseOrderForm.comments.value;
    var errorMsgForPoMaxAmt = checkAmount(poMaxAmt, "PO Max Amount");    
    <logic:lessEqual value="0" property="purchaseOrder_id"  name="openPurchaseOrderForm" >
    var poNumberCtrl = document.openPurchaseOrderForm['poNumber'];
    if (poNumberCtrl.value.trim() == '')
    {
        poNumberCtrl.focus();
        errors = errors + "<li> Please enter PO Number";
    }
    else
    {
        if (chkSalesOrderNoBegin(poNumberCtrl.value.trim()))
        {
            poNumberCtrl.focus();
            errors = errors + "<li>PO Number should not start with special characters ";
        }
        else
            if (! chkSalesOrderNo(poNumberCtrl.value.trim()))
            {
                poNumberCtrl.focus();
                errors = errors + "<li>Please enter valid PO Number";
            }
    }
    </logic:lessEqual>
    if (errorMsgForPoMaxAmt != '')
    {
        errors = errors + "<li>" + errorMsgForPoMaxAmt;
    }
    var shippingMethodIdCtrl = document.openPurchaseOrderForm.shippingMethodId;
    var payTermsCtrl = document.openPurchaseOrderForm.payTerms;
    if (shippingMethodIdCtrl.value == -1)
    {
        errors += "<li> Please select <bean:message key="label.sales.salesOrder.ShippingMethod" />";
    }
    else if ( shippingMethodIdCtrl.value == -2 )
    {
        if ( document.openPurchaseOrderForm.newShippingMethod.value.trim().length == 0 )
        {
            errors += "<li> Please enter New Shipping Method";
        }
        if ( document.openPurchaseOrderForm.newShippingAccount.value.trim().length == 0 )
        {
            errors += "<li> Please enter New Shipping Account";
        }
    }
    if ( payTermsCtrl.value == -1 )
    {
        errors += "<li> Please select Pay Terms";
    }
    else if ( payTermsCtrl.value == -2 )
    {
        if ( document.openPurchaseOrderForm.newPayTerms.value.trim().length == 0 )
        {
            errors += "<li> Please enter New Pay Terms";
        }
    }
    if( errors == '')
    {
        var issuedAmt = parseFloat( document.getElementById("issuedAmt").value ).toFixed(2);
        if ( isNaN ( issuedAmt ) == true )
        {
            issuedAmt = 0;
        }
        if( parseFloat( poMaxAmt) < parseFloat( issuedAmt ))
        {
            errors = "<li>" + "PO Max Amount cannot be less than Issued Amount ($"+issuedAmt+")";
        }
    }
    if ( chkDate( validFromDate, "Valid-From date","Y") == false )
    {
        errors = errors + errMsg;
    }
    if ( chkDate( validToDate, "Valid-To date", "Y") == false )
    {
        errors = errors + errMsg;
    }
    if( (chkDate( validFromDate, "Valid-From date","Y") == true) && (chkDate( validToDate, "Valid-To date", "Y")) )
    {
        if( CompareDate( validFromDate, validToDate) == false )
        {
            errors = errors + "<li>Valid-From date must not be greater than Valid-To date";
        }
    }
    if( (chkDate( validFromDate, "Valid-From date","Y") == true) && (chkDate( poDate, "PO date", "Y")) )
    {
        if( CompareDate( poDate, validFromDate) == false )
        {
            errors = errors + "<li>Valid-From date should not less than PO date";
        }
    }
    if( commentsValue.length > commentsMaxLength )
    {
        errors = errors + "<li>Comments cannot exceed "+commentsMaxLength+" characters";
    }

    if ( errors != '' )
    {
        var errorIndex = document.getElementById("errorIndex");
        errorIndex.innerHTML = errors;
        errorIndex.focus();
        return;
    }

    // added by murali krishna, in pending purchase order, cancel is disabled, this must be enabled before submiting.
    var cancelChk = document.openPurchaseOrderForm.cancel;
    if ( cancelChk )
    {
        cancelChk.disabled = false;
    }

	document.openPurchaseOrderForm.action = '<%=chipTracContext%>/openPurchaseOrder.do?action=confirm';
	document.openPurchaseOrderForm.submit();
}

function createOpenPO()
{
	var path = document.openPurchaseOrderForm.path.value;

	if( path == null || path == 'create' )
	{
		document.openPurchaseOrderForm.action = '<%=chipTracContext%>/purchaseOrders.do?action=Generate';
	}
	else if ( path == 'searchChangePurchaseOrder' )
	{
		document.openPurchaseOrderForm.action = '<%=chipTracContext%>/searchPurchaseOrders.do?action=searchChangePurchaseOrder';
	}
	else if( path == 'searchPendingPurchaseOrder' )
	{
		document.openPurchaseOrderForm.action = '<%=chipTracContext%>/searchPurchaseOrders.do?action=searchPendingPurchaseOrder';
	}
	else
	{
		document.openPurchaseOrderForm.action = '<%=chipTracContext%>/purchaseOrders.do?action=Generate';
	}
	document.openPurchaseOrderForm.submit();
}

function loadShippingAddress()
{
	document.openPurchaseOrderForm.shippingAddressAsString.value = shipAddress[document.openPurchaseOrderForm.contactPerson.selectedIndex].replace(/~/g,'\n');
}
function loadShippingAddress1()
{
	document.openPurchaseOrderForm.shippingAddressAsString.value = vendorShipAddress[document.openPurchaseOrderForm.vendorAddressId.selectedIndex].replace(/~/g,'\n');
}
function checkAmount(fieldValue,fieldName )
{
    if ( (checkFloat( fieldValue, fieldName, 'Y' ) == false) )
    {
        return errMsg;
    }
    if(check_char_position4(fieldValue) || (is_Sp_Characters_frieght(fieldValue) == false)  )
    {
        return "Please enter a valid "+fieldName;
    }
    if( fieldValue.length >= 8 )
    {
        var index = fieldValue.indexOf(".");
        if( index == -1 || index > 7 )
        {
            return "Please enter a valid "+fieldName+" (amount should be in XXXXXXX.XX format)";
        }
    }
    return '';
}
function showHideNewShippingMethod()
{
    var form = document.openPurchaseOrderForm;
    var shippingMethodId = form.shippingMethodId.value;
    var shippingMethodIdCtrl = form.shippingMethodId;
    var newShippingMtdTable = document.getElementById( "newShippingMtdTable" ) ;
    var shipMethodCtrl = form.shipMethod;
    var shipAccountCtrl = form.shipAccount;

    if ( shippingMethodId == -2 )
    {
        newShippingMtdTable.style.display = "block"
        shipMethodCtrl.value = ""
    }
    else
    {
        newShippingMtdTable.style.display = "none"
        if ( shippingMethodId == -1 )
        {
            shipMethodCtrl.value = "";
        }
        else
        {
            shipMethodCtrl.value = shippingMethodIdCtrl.options[shippingMethodIdCtrl.selectedIndex].text
        }
    }
}
function showHideNewPayTerms()
{
    var form = document.openPurchaseOrderForm;
    var payTerms = form.payTerms.value;
    var payTermsLabel = document.getElementById( "payTermsLabel" ) ;
    var newPayTermsCtrl = form.newPayTerms;
    if ( payTerms == -2 )
    {
        payTermsLabel.style.display = "block"
        newPayTermsCtrl.style.display = "block"
    }
    else
    {
        payTermsLabel.style.display = "none"
        newPayTermsCtrl.style.display = "none"
    }
}
function init()
{
    showHideNewShippingMethod();
    showHideNewPayTerms();
}
</SCRIPT>
</HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="init()">

<!-- Top Header Start-->
<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
	<TBODY>
	<TR>
		<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
		<!-- Side Navigation start -->
			<%@include file="/jsp/finance/purchase_order_menu.jsp" %>
		<!-- end of the side navigations -->
		</td>

		<td bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></td>
		<td bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td>
		<td valign="top" width="100%">
		<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
		<BR>
		<html:form method="post" name="openPurchaseOrderForm" action="/openPurchaseOrder" type="com.scalar.chiptrack.finance.openpo.forms.OpenPurchaseOrderForm">
            <input type="hidden" name="issuedAmt" value="<bean:write name="openPurchaseOrderForm" property="poIssuedAmt"/>">
			<center><span class="NArialW">Open Purchase Order</span></center>
			<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
			<TABLE width='95%' align='center' border='0' bordercolor='red'>
				<tr><td width="25%"></td><td width="25%"></td><td width="25%"></td><td width="25%"></td></tr>
				<html:hidden name="openPurchaseOrderForm" property="purchaseOrder_id"/>
				<html:hidden name="openPurchaseOrderForm" property="vendor_id"/>
				<html:hidden name="openPurchaseOrderForm" property="poType"/>
				<html:hidden name="openPurchaseOrderForm" property="poDate"/>
				<html:hidden name="openPurchaseOrderForm" property="billingAddress_id"/>
				<html:hidden name="openPurchaseOrderForm" property="shippingAddress_id"/>
				<html:hidden name="openPurchaseOrderForm" property="path"/>
                <tr><td colspan="4">&nbsp;&nbsp;</td></tr>
				<tr><td colspan="4"><chiptrack:errors styleClass="NArialL"/></td></tr>
				<tr><td colspan="4"><chiptrack:info styleClass="NArialL"/></td></tr>
                <tr><td colspan="4" id="errorIndex" style='color:#FF0000' class='NArialL'></td></tr>
				<tr><td colspan="4">&nbsp;&nbsp;</td></tr>
				<tr>
					<td><font class='NArialL'>PO Number :</font></td>
					<td><font class='bodytext'>
                        <nested:greaterThan property="purchaseOrder_id" value="0" >
                            <nested:write property="poNumber"/>
                        </nested:greaterThan>
                        <nested:lessEqual value="0" property="purchaseOrder_id">
                            <nested:text size="10" styleClass="txfield" property="poNumber" maxlength="50"/>
                        </nested:lessEqual>
                    </font></td>
					<td><font class='NArialL'>PO Type :</font></td>
					<td><font class='bodytext'><bean:write name="openPurchaseOrderForm" property="POTypeString"/></td>
				</tr>
				<tr>
					<td><font class='NArialL'>Vendor Name :</font></td>
					<td class='bodytext'><bean:write name="openPurchaseOrderForm" property="vendorName"/></td>
					<td><font class='NArialL'>PO Date :</font></td>
					<td><font class='bodytext'><bean:write name="openPurchaseOrderForm" property="poDate"/></td>
				</tr>
				<logic:notEqual name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
				<tr>
					<td><font class='NArialL'>PO Max $ : <font color=red>*</font></font></td>
					<td><html:text name="openPurchaseOrderForm" property="poMaxAmt" styleClass='valuetxfield' size='11' onkeypress="javascript:restrictCharacters(this,7,2)" onkeyup="javascript:restrictAmt(this,7,2)" maxlength="10"/></td>
					<td><font class='NArialL'>Vendor Quote No. :</font></td>
					<td><html:text name="openPurchaseOrderForm" property="vendorQuoteNumber" styleClass='txfield' maxlength="50"/></td>
				</tr>
				<tr>
					<td><font class='NArialL'>Valid From : <font color=red>*</font></font></td>
					<td><html:text styleClass='txfield' size='11' name='openPurchaseOrderForm' property="validFromDate"/>
						<a href="javascript:openCalendar(document.openPurchaseOrderForm.validFromDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
					</td>
					<td><font class='NArialL'>Valid To : <font color=red>*</font></font></td>
					<td><html:text styleClass='txfield' size='11' name='openPurchaseOrderForm' property="validToDate"/>
						<a href="javascript:openCalendar(document.openPurchaseOrderForm.validToDate)"><img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
					</td>
				</tr>
				</logic:notEqual>

				<logic:equal name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
				<tr>
					<td><font class='NArialL'>PO Max $ : <font color=red>*</font></font></td>
					<td>
					<font class='bodytext'><bean:write name="openPurchaseOrderForm" property="poMaxAmt"/></font>
					<html:hidden name="openPurchaseOrderForm" property="poMaxAmt"/>
					</td>
					<td><font class='NArialL'>Vendor Quote No. :</font></td>
					<td>
					<font class='bodytext'><bean:write name="openPurchaseOrderForm" property="vendorQuoteNumber"/></font>
					<html:hidden name="openPurchaseOrderForm" property="vendorQuoteNumber"/>
					</td>
				</tr>
				<tr>
					<td><font class='NArialL'>Valid From : <font color=red>*</font></font></td>
					<td>
					<font class='bodytext'><bean:write name='openPurchaseOrderForm' property="validFromDate"/></font>
					<html:hidden name="openPurchaseOrderForm" property="validFromDate"/>
					</td>
					<td><font class='NArialL'>Valid To : <font color=red>*</font></font></td>
					<td>
					<font class='bodytext'><bean:write name='openPurchaseOrderForm' property="validToDate"/></font>
					<html:hidden name='openPurchaseOrderForm' property="validToDate"/>
					</td>
				</tr>
				</logic:equal>

				<logic:notEqual name="openPurchaseOrderForm" property="purchaseOrder_id" value="-1" >
				<tr>
					<td><font class='NArialL'>PO Rev :</font></td>
					<td><font class='bodytext'><bean:write name="openPurchaseOrderForm" property="poRev" /></font></td>
					<td><font class='NArialL'>PO Last Modified date :</font></td>
					<td><font class='bodytext'><bean:write name="openPurchaseOrderForm" property="poLastModifiedDate"/></font></td>
				</tr>
				<tr>
					<td><font class='NArialL'>Issued PO $ :</font></td>
					<td><font class='bodytext'><bean:write name="openPurchaseOrderForm" property="poIssuedAmt"/></font></td>
					<td><font class='NArialL'>Remaining PO $ :</font></td>
					<td><font class='bodytext'><bean:write name="openPurchaseOrderForm" property="poRemainingAmt"/></font></td>
				</tr>
				</logic:notEqual>
				<tr>
					<td><font class='NArialL'>Holds :</font></td>
					<td colspan='2'><font class='NArialL'>Fin : </font>
						<logic:equal name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
						<html:select name="openPurchaseOrderForm" property="financeHold" styleClass="txfield">
							<html:options collection="financeReasonCodes" property="value" labelProperty="label" />
						</html:select>
						&nbsp;<font class='NArialL'> Ops : </font>
						<html:select name="openPurchaseOrderForm" property="operationsHold" styleClass="txfield">
							<html:options collection="opsReasonCodes" property="value" labelProperty="label" />
						</html:select>
						</logic:equal>
                        <logic:notEqual name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
						<html:select name="openPurchaseOrderForm" property="financeHold" styleClass="txfield" disabled="true">
							<html:options collection="financeReasonCodes" property="value" labelProperty="label" />
						</html:select>
						<html:hidden name="openPurchaseOrderForm" property="financeHold"/>
						&nbsp;<font class='NArialL'> Ops : </font>
						<html:select name="openPurchaseOrderForm" property="operationsHold" styleClass="txfield" disabled="true" >
							<html:options collection="opsReasonCodes" property="value" labelProperty="label" />
						</html:select>
						</logic:notEqual>
						<html:hidden name="openPurchaseOrderForm" property="operationsHold"/>
					</td>
					    <td class='NArialL' align='right'>
                            <logic:equal name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
                               <A href="javascript:openReasonCodes();"onmouseover="window.status='Click for Reason Codes';return true" onmouseout="window.status='';return true" >ReasonCodes Description</A>
                            </logic:equal>
					    </td>
				</tr>
                <logic:notEqual name="openPurchaseOrderForm" property="purchaseOrder_id" value="-1">
                <%
                    String action = request.getParameter( "action" );
                    if( action != null &&( ( Constants.ACTION_UPDATE .equalsIgnoreCase( action ) )||( Constants.ACTION_LOAD .equalsIgnoreCase( action ) )||( Constants.ACTION_EDIT .equalsIgnoreCase( action ) ) ) )
                    {
                %>
                        <tr><td colspan='4' height=10></td></tr>
                        <tr>
                            <td><font class='NArialL'>Cancel :</font></td>
                            <td>
                                <logic:notEqual name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
                                    <html:checkbox styleClass='txfield' name="openPurchaseOrderForm" property="cancel"/>
                                </logic:notEqual>
                                <logic:equal name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
                                    <html:checkbox styleClass='txfield' name="openPurchaseOrderForm" property="cancel" disabled="true"/>
                                </logic:equal>
                            </td>
                            <td colspan='2'>&nbsp;</td>
                        </tr>
                <%
		            }
	            %>
                </logic:notEqual>
                <%
                    boolean disabled = false;
                %>
                <logic:equal name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
                    <%
                        disabled = true;
                    %>
                </logic:equal>
                <tr>
                    <td>
                        <font class='NArialL'><bean:message key="label.sales.salesOrder.ShippingMethod" /> : <font color=red>*</font></font>
                    </td>
					<td>
                        <nested:hidden property="shipMethod"/>
                        <nested:select styleClass='txfield' property="shippingMethodId" onchange="showHideNewShippingMethod()" disabled="<%=disabled%>">
                            <html:option value="-1">--- Select ---</html:option>
                            <nested:optionsCollection property="shippingMethodsList" label="label" value="value"/>
                            <html:option value="-2" >-- Add <bean:message key="label.sales.salesOrder.NewShippingMethod"/> --</html:option>
                        </nested:select>
                    </td>
					<td>
                        <font class='NArialL'>Pay Terms : <font color=red>*</font></font>
                    </td>
					<td>
					    <nested:select styleClass='txfield' property="payTerms" onchange="showHideNewPayTerms()" disabled="<%=disabled%>">
                            <html:option value="-1">--- Select ---</html:option>
                            <nested:options property="payTermsList" />
                            <html:option value="-2" >-- Add New Pay Terms --</html:option>
                        </nested:select>
					</td>
                </tr>
                <tr>
                    <td colspan="2" class='NArialL'>
                        <table id="newShippingMtdTable">
                            <tr class='NArialL'>
                                <td>New Shipping Method:</td>
                                <td>New Shipping Account:</td>
                            </tr>
                            <tr>
                                <td align="center"><nested:text property="newShippingMethod" styleClass="txfield" size="18" maxlength="100"/></td>
                                <td align="center"><nested:text property="newShippingAccount" styleClass="txfield" size="18" maxlength="50"/></td>
                            </tr>
                        </table>
                    </td>
					<td>
                        <font class='NArialL' id="payTermsLabel"> New Pay Terms:<!-- <font color=red>*</font>--></font>
                    </td>
					<td>
					    <nested:text property="newPayTerms" styleClass="txfield" size="18"/>
					</td>
                </tr>
                <logic:equal name="openPurchaseOrderForm" property="purchaseOrder_id" value="-1" >
                <tr>
                    <td><font class='NArialL'>&nbsp;</font></td>
                    <td>
                        &nbsp;
                    </td>
                    <td><font class='NArialL'>Sales Addresses :</font></td>
                    <td>
                        <html:select name="openPurchaseOrderForm" property="vendorAddressId" styleClass="txfield" onchange="javascript:loadShippingAddress1();">
                            <html:optionsCollection property="shippingVendorsList" name="openPurchaseOrderForm" label="label" value="value" />
                        </html:select>
                    </td>
                </tr>
                </logic:equal>

                <logic:equal name="openPurchaseOrderForm" property="purchaseOrder_id" value="-1" >
				<tr>
					<td><font class='NArialL'>&nbsp;</font></td>
					<td>
						&nbsp;
					</td>
					<td><font class='NArialL'>Ship To Contact Person :</font></td>
					<td>
						<html:select name="openPurchaseOrderForm" property="contactPerson" styleClass="txfield" onchange="javascript:loadShippingAddress();">
							<html:optionsCollection property="shippingContactPersonList" name="openPurchaseOrderForm" label="label" value="value" />
						</html:select>
					</td>
				</tr>
				</logic:equal>
				<tr>
					<td><font class='NArialL'>Bill To Address :</font></td>
					<td><html:textarea rows='11' cols="25" name="openPurchaseOrderForm" property="billingAddressAsString" styleClass='txfield' disabled="true"/></td>
					<td><font class='NArialL'>Ship To Address :</font></td>

                    <td><html:textarea rows='11' cols="25" name="openPurchaseOrderForm" property="shippingAddressAsString" styleClass='txfield' disabled="true"/></td>
				<%--<tr><td colspan='4' height=10>&nbsp;</td></tr>--%>
				<tr><td colspan='4' height=10>&nbsp;</td></tr>
				<logic:notEqual name="openPurchaseOrderForm" property="purchaseOrder_id" value="-1" >
				<tr>
					<td colspan='2' class="NArialL"> <a HREF="javascript:openAuditTrail(<bean:write name="openPurchaseOrderForm" property="purchaseOrder_id"/>, '<bean:write name="openPurchaseOrderForm" property="poNumber"/>' );" onmouseover="window.status='Click to Audit Trail';return true" onmouseout="window.status='';return true" >Audit Trail</a>
					</td>
					<td colspan='2' class="NArialL" align='right'> <%--<a HREF="javascript:openRelatedPOsScreen(<bean:write name="openPurchaseOrderForm" property="purchaseOrder_id"/>);" onmouseover="window.status='Click to Audit Trail';return true" onmouseout="window.status='';return true" >POs generated against this Open PO</a>--%>
					</td>
				</tr>
				<tr><td colspan='4' height=10>&nbsp;</td></tr>
				</logic:notEqual>
				<tr>
					<td><font class='NArialL'>Comments :</font></td>
					<td colspan="2">
                    <logic:notEqual name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
                        <html:textarea rows='5' cols="60" name="openPurchaseOrderForm" property="comments" styleClass='txfield' onkeyup='setTextAreaMaxLength(this, 300)'/>
                    </logic:notEqual>
                    <logic:equal name="openPurchaseOrderForm" property="path" value="searchPendingPurchaseOrder">
                        <font class='bodytext'><html:textarea rows='5' cols="60" name="openPurchaseOrderForm" property="comments" styleClass='txfield' disabled='true'/></font>
                    </logic:equal>
                    </td>
					<td>&nbsp;</td>
				</tr>
				<tr><td colspan='4' height=10>&nbsp;</td></tr>
				<tr><td colspan='4' height=10>&nbsp;</td></tr>
				<tr>
					<td colspan='4' align='center'>
						<a href="javascript:generatePurchaseOrder();" class="leftsection" onmouseover="window.status='';return true" onmouseout="window.status='';return true">
							<img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" title="" ></a>
						<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width='50' height='10'>
						<a href="javascript:createOpenPO();" class="leftsection" onmouseover="window.status='';return true" onmouseout="window.status='';return true">
						<img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" title="" ></a>
					</td>
				</tr>
			</table>
		</html:form><BR><BR><BR>
		</TD>
		<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
	</TR>
</TABLE>
<logic:equal name="openPurchaseOrderForm" property="purchaseOrder_id" value="-1" >
<SCRIPT language="javascript">
onloadSetShippingAddress();
</SCRIPT>
</logic:equal>

<!-- Footer starts here -->
<%@include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>

<%
    }
    catch ( Exception e)
    {
        e.printStackTrace();
    }
%>